#include "NativeHost.h"

using namespace GUIToolkit;

NativeHost::NativeHost(float x, float y, float width, float height, LPWSTR text)
	: HwndHost(), rect(x, y, width, height)
{
	this->SetText(text);
}

void NativeHost::Paint(Graphics* g)
{
	this->Update();
}

void NativeHost::OnPropertyChanged(PROPERTY p)
{
	if(p == PROPERTY::UI_ROOT)
	{
		this->Detach();
		auto ui = dynamic_cast<HwndHost*>(this->GetRoot());
		if(ui != NULL)
		{
			this->Create(ui->GetHandle(), &rect);
			this->Show();
		}
	}
	HwndHost::OnPropertyChanged(p);
}

NativeHost::~NativeHost(void)
{
}


//---Button----------------
NativeButton::NativeButton(float x, float y, float width, float height, LPWSTR text)
	: NativeHost(x, y, width, height, text)
{
	
}

void NativeButton::Create(HWND hWnd, RectF* rect)
{
	HwndHost::Create(this->GetText().c_str(), L"Button", hWnd, WS_CHILDWINDOW | WS_VISIBLE, 0, rect);
}

NativeButton::~NativeButton(void)
{
}